
#include <iostream>
#include <string>

// Step 1: 定义子系统 (Subsystem)

// 音响系统
class SoundSystem {
public:
    void turnOn() {
        std::cout << "Sound System: Turned on." << std::endl;
    }

    void turnOff() {
        std::cout << "Sound System: Turned off." << std::endl;
    }

    void setVolume(int level) {
        std::cout << "Sound System: Volume set to " << level << "." << std::endl;
    }
};

// 投影仪系统
class Projector {
public:
    void turnOn() {
        std::cout << "Projector: Turned on." << std::endl;
    }

    void turnOff() {
        std::cout << "Projector: Turned off." << std::endl;
    }

    void setMode(const std::string& mode) {
        std::cout << "Projector: Mode set to " << mode << "." << std::endl;
    }
};

// 播放器系统
class MediaPlayer {
public:
    void turnOn() {
        std::cout << "Media Player: Turned on." << std::endl;
    }

    void turnOff() {
        std::cout << "Media Player: Turned off." << std::endl;
    }

    void playMovie(const std::string& movie) {
        std::cout << "Media Player: Playing movie '" << movie << "'." << std::endl;
    }
};

// 灯光系统
class Lighting {
public:
    void dim(int level) {
        std::cout << "Lighting: Dimmed to " << level << "%." << std::endl;
    }

    void restore() {
        std::cout << "Lighting: Restored to full brightness." << std::endl;
    }
};

// Step 2: 定义外观类 (Facade)
class HomeTheaterFacade {
private:
    SoundSystem soundSystem_;
    Projector projector_;
    MediaPlayer mediaPlayer_;
    Lighting lighting_;

public:
    // 提供统一的接口控制子系统
    void watchMovie(const std::string& movie) {
        std::cout << "Preparing to watch movie: " << movie << std::endl;
        lighting_.dim(30);
        projector_.turnOn();
        projector_.setMode("Cinema");
        soundSystem_.turnOn();
        soundSystem_.setVolume(10);
        mediaPlayer_.turnOn();
        mediaPlayer_.playMovie(movie);
        std::cout << "Enjoy your movie!" << std::endl;
    }

    void endMovie() {
        std::cout << "Shutting down home theater system." << std::endl;
        mediaPlayer_.turnOff();
        soundSystem_.turnOff();
        projector_.turnOff();
        lighting_.restore();
        std::cout << "Goodbye!" << std::endl;
    }
};

// Step 3: 客户端代码
int main() {
    HomeTheaterFacade homeTheater;

    // 通过外观类看电影
    homeTheater.watchMovie("Inception");

    // 结束电影
    homeTheater.endMovie();

    return 0;
}